const cryptoModule = require('./module/cryptoHelper');
const jwtModule = require('./module/jwtHelper');
const fielModule = require('./module/fileHelper');
const dbHelper = require('./module/dbHelper');

module.exports = {
  ...cryptoModule,
  ...jwtModule,
  ...fielModule,
  ...dbHelper,
  /**
   * 返回按照ASCII排序后的对象
   * @param {object} obj 目标对象
   * @param {Boolean} isSort true代表升序，false代表降序
   * */
  sortASCII(obj, isSort) {
    const arr = [];
    Object.keys(obj).forEach(item => arr.push(item));
    const sortArr = isSort ? arr.sort() : arr.sort().reverse();
    const sortObj = {};
    for (const i in sortArr) {
      sortObj[sortArr[i]] = obj[sortArr[i]];
    }
    return sortObj;
  },
};
